import request from '@/utils/axiosRequest'
import useEnv from "@/hooks/useEnv";
const upload = useEnv.VITE_FILE_API + "/upload"
const show = useEnv.VITE_FILE_API + "/shows?uuid="

const getUser = (id) => {
    return request({
        url: '/user/getUserById?userId=' + id
    })
}

const getFollows = (id) => {
    return request({
        url: '/follow/follows?userId=' + id
    })
}
const getFans = (id) => {
    return request({
        url: '/fans/fans?userId=' + id
    })
}
const selectByUserId = (data) => {
    return request({
        url: '/photo/selectByUserId?index=' + data.index + '&size=' + data.size + '&searchName=' + data.name + '&searchValue1=' + data.userId
    })
}

const getMyself = () => {
    return request({
        url: '/user/myself'
    })
}

const checkCodeByEmail = (code) => {
    return request({
        url: '/identity/checkCodeByEmail?code=' + code
    })
}

const sendEmail = () => {
    return request({
        url: '/identity/sendEmailByMyself'
    })
}
const passwordChangeByEmailAndCode = (data) => {
    return request({
        url: '/identity/passwordChangeByEmailAndCode',
        data: data,
        method: 'post'
    })
}
const updateAvatar = (uuid) => {
    return request({ url: '/user/updateAvatar?uuid=' + uuid })
}

const updateUser = (data) => {
    return request({
        url: '/user/updateInfo',
        data: data,
        method: 'post'
    })
}
const getCategory = () => {
    return request({
        url: '/category/get'
    })
}
const updatePhoto = (data) => {
    return request({
        url: '/photo/update',
        data: data,
        method: 'post'
    })
}

const delPhoto = (id) => {
    return request({
        url: '/photo/delete?id=' + id,
        method: 'delete'
    })
}

const likeByMySelf = (x) => {
    return request({ url: '/like/likeByMy?index=' + x.index + '&size=' + x.size + '&searchName=' + x.name })
}

const watchByMyself = () => {
    return request({ url: '/userwatch/selectByMyself' })
}



export default {
    upload,
    show,
    getUser,
    getFollows,
    getFans,
    selectByUserId,
    getMyself,
    checkCodeByEmail,
    sendEmail,
    passwordChangeByEmailAndCode,
    updateAvatar,
    updateUser,
    getCategory,
    updatePhoto,
    delPhoto,
    watchByMyself,
    likeByMySelf

}

